//
//  NSString+BP.m
//  Tools
//
//  Created by lanou on 15/12/13.
//  Copyright (c) 2015年 lanou. All rights reserved.
//

#import "NSString+BP.h"

@implementation NSString (BP)

- (CGSize)sizeWithFont:(UIFont *)font constrainedToSize:(CGSize)size{
    
    NSDictionary *fontDic = @{NSFontAttributeName :font};
    
    
    CGRect textRect = [self boundingRectWithSize:size options:( NSStringDrawingUsesLineFragmentOrigin) attributes:fontDic context:nil];
    
    return textRect.size;
    
    
}

- (CGRect)rectwithFont:(UIFont *)font frame:(CGRect)frame{
    
    CGSize newSize = [self sizeWithAttributes:@{NSFontAttributeName:font}];
    
    CGRect newFrame = frame;
    
    newFrame.size.width = newSize.width + 5;
    
    frame = newFrame;
    
    return frame;
    
    
    
    
    
}


@end
